import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { MarketOneInfo } from "./info/MarketOneInfo";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
type int = number;
//class MarketOneConfig
    
    export  class MarketOneConfig
    {
        constructor()
        {
            
            this._sellInfoMap = new Map<any, any> /* flash.utils.Dictionary */();
            this._seekBuyInfoMap = new Map<any, any> /* flash.utils.Dictionary */();
            if (MarketOneConfig._instance != null) 
            {
                throw new Error("MarketOneConfig单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_market_one.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc1=[];
            var loc5=0;
            var loc6=arg1;
            for(loc3 of loc6) 
            {
                loc2 = new MarketOneInfo();
                loc2.oneId = loc3.oneId;
                loc2.oneIndex = loc3.oneIndex;
                loc2.oneName = StringHelper.getString(loc3.oneName);
                loc2.marketType = loc3.marketType;
                loc1.push({"info": loc2, "id": loc2.oneId});
                loc1.sortOn("id", Array.NUMERIC);
            }
            loc4 = 0;
            while (loc4 < loc1.length) 
            {
                loc2 = loc1[loc4].info;
                if (loc2.marketType != 0) 
                {
                    if (loc2.marketType == 1) 
                    {
                        this._seekBuyInfoMap[loc2.oneId - this.sellInfoNum] = loc2;
                    }
                }
                else 
                {
                    this._sellInfoMap[loc2.oneId] = loc2;
                    this.sellInfoNum = this.sellInfoNum + 1;
                }
                ++loc4;
            }
            return;
        }

        public MarketOneConfig.get firstSellInfoTagMap(): Map<any, any> /* flash.utils.Dictionary */
        {
            return this._sellInfoMap;
        }

        public MarketOneConfig.get firstSeekBuyInfoTagMap(): Map<any, any> /* flash.utils.Dictionary */
        {
            return this._seekBuyInfoMap;
        }

        public static get instance(): MarketOneConfig
        {
            if (MarketOneConfig._instance == null) 
            {
                MarketOneConfig._instance = new MarketOneConfig();
            }
            return MarketOneConfig._instance;
        }

        /* internal */ /* var */_sellInfoMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_seekBuyInfoMap: Map<any, any> /* flash.utils.Dictionary */;

        public /* var */sellInfoNum: int=0;

        /* internal */ static /* var */_instance: MarketOneConfig;
    }
